package com.dmall.algorithm.chapter02.section05;

public class MyPow {

    double pow(double x, int n) {
        assert n >= 0;
        if (n == 0) {
            return 1.0;
        }
        double t = pow(x, n / 2);
        if (n % 2 == 1) {
            return x * t * t;
        }
        return t * t;
    }

    public static void main(String[] args) {
        MyPow myPow = new MyPow();
        System.out.println(myPow.pow(5, 5));
    }
}
